package com.hxd.qzg.common;

import java.io.Serializable;


//@JsonInclude(Include.NON_NULL)
public class Result implements Serializable {

	private static final long serialVersionUID = 1L;

	public static final int SUCCESS_CODE = 1000;

	public static final int FAILURE_CODE = 900;

	private int code;

	private String msg;

	private Object data;

	// 异常信息
	private String exceptionMessage;

	// report 打印用 其它忽略
	private String report;

	public String getReport() {
		return report;
	}

	public void setReport(String report) {
		this.report = report;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public static int getSuccessCode() {
		return SUCCESS_CODE;
	}

	public static int getFailureCode() {
		return FAILURE_CODE;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Result() {

	}

	public Result(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public Result(int code, String msg, Object data) {
		this(code, msg);
		this.data = data;
	}

	public Result(int code, String msg, Object data, String exceptionMessage) {
		this(code, msg);
		this.data = data;
		this.exceptionMessage = exceptionMessage;
	}

	public static Result success() {
		return new Result(SUCCESS_CODE, "200");
	}

	public static Result success(Object obj) {
		return new Result(SUCCESS_CODE, "200", obj);
	}

	public static Result success(Object obj, String report) {
		Result result = new Result(SUCCESS_CODE, "200", obj);
		result.setReport(report);
		return result;
	}

	public static Result failure(int code, String message) {
		return new Result(code, message);
	}
	public static Result failure(String message) {
		return new Result(FAILURE_CODE, message);
	}

	public static Result error(String message) {
		return new Result(FAILURE_CODE, message);
	}

	public boolean isSuccess() {
		if (SUCCESS_CODE == this.code) {
			return true;
		}
		return false;
	}

	public String getExceptionMessage() {
		return exceptionMessage;
	}

	public void setExceptionMessage(String exceptionMessage) {
		this.exceptionMessage = exceptionMessage;
	}

	@Override
	public String toString() {
		return "Result{" + "code=" + code + ", msg='" + msg + '\'' + ", data=" + data + '}';
	}
}
